package com.gitee.huxing.course.conc.task;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Description:
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.conc.task
 * @ClassName: TaskService01Impl
 * @Author: huxing
 * @DateTime: 2021-08-25 下午4:58
 */
public class TaskThreadPool11 extends AbstractTaskThreadPool{

    public static AtomicInteger atomicInteger = new AtomicInteger(0);

    public static void main(String[] args) throws InterruptedException{
        new TaskThreadPool11().task();
    }

    @Override
    public int threadTask() {
        CompletableFuture.supplyAsync(CourseTask::sum)
                        .thenAccept(v -> atomicInteger.set(v)).join();
        return atomicInteger.get();
    }
}
